Skip to content

[DependencyInjection] Compiler pass bundle example does not implement CompilerPassInterface #20665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

jennevdmeer
Copy link
Contributor

@jennevdmeer jennevdmeer commented Feb 18, 2025

Not much more to add.

If your compiler pass is relatively small, you can add it directly in the main
bundle class. To do so, make your bundle implement the
:class:`Symfony\\Component\\DependencyInjection\\Compiler\\CompilerPassInterface`
and place the compiler pass code inside the ``process()`` method of the main
bundle class::
// src/MyBundle/MyBundle.php
namespace App\MyBundle;
use App\DependencyInjection\Compiler\CustomPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
class MyBundle extends AbstractBundle
{
public function process(ContainerBuilder $container): void
{

It adds the import/implements to this part.

@javiereguiluz
Copy link
Member

Good catch, thanks Jenne.

@javiereguiluz javiereguiluz merged commit d3d5a44 into symfony:6.4 Feb 19, 2025
3 checks passed
@jennevdmeer jennevdmeer deleted the patch-2 branch February 19, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants